#!/usr/bin/python
# -*- coding: utf-8 -*-
# File: signals.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Signals manager for Vazaar

import os

import gobject
import gtk

from vazaarlib.utils import get_logger

class SignalManager():
    def __init__(self, gui):
        self.gui = gui
        self.log = get_logger("SignalMgr")
        self.setup()

    def setup(self):
        #widget/signal : function
        self.gui.frontend['connections'] = {
            'winMain/delete_event' :    self.gui.actions.hide_application,
            'winMain/key_press_event' : self.gui.events.on_key_press,
            'winMain/configure_event' : self.gui.events.configure_event,
        }

        #connect signals
        for wid_con, func in self.gui.frontend['connections'].iteritems():
            wid,con = wid_con.split('/')
            try:
                self.gui.glade[wid].connect(con,func)
            except Exception, e:
                self.log.debug("Error connecting signals: %s" % e)
                #raise

        self.visible = False

